import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class MainB {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int t = T; t > 0; t--) {
            int N = in.nextInt();
            int M = in.nextInt();
            List<Integer>[] edges = new ArrayList[N + 1];

            for (int i = 0; i < M; i++) {
                int a = in.nextInt();
                int b = in.nextInt();

                if (edges[a] == null) {
                    edges[a] = new ArrayList<>();
                }
                edges[a].add(b);

                if (edges[b] == null) {
                    edges[b] = new ArrayList<>();
                }
                edges[b].add(a);

            }
            boolean flag = true;
            for (int i = 1; i <= N; i++) {
                if (edges[i].size() < 2) {
                    flag = false;
                    break;
                }
            }
            System.out.println(flag? "Yes" : "No");
        }

    }
}
